<?php

namespace app\api\controller\event;

use app\api\service\event\OperationService;
use app\lib\exception\event\OperationException;
use think\Request;

class Operation
{
    protected $Service;
    public function __construct()
    {
        $this->Service = OperationService::getInstance();
    }

    /**
     * @auth('商户注册审核列表','运营管理')
     * @param Request $request
     * @return \think\response\Json
     */
    public function getMerchantRegisterList(Request $request){
        $params = $request->get();
        $result = $this->Service->getMerchantRegisterList($params);
        return writeJson(201, $result, '数据列表');
    }



    /**
     * @auth('商户注册审核反馈','运营管理')
     * @param Request $request
     * @param('id','商户id','require')
     * @param('status','商户状态','require')
     * @return \think\response\Json
     */
    public function checkRegister(Request $request){
        $params = $request->put();
        $this->Service->checkRegister($params);
        return writeJson(201, '', '商户注册审核状态变更');
    }

    /**
     * @auth('商户订单审核列表','运营管理')
     * @param Request $request
     * @param('page','页数','require')
     * @return \think\response\Json
     */
    public function getMerchantOrderList(Request $request){
        $params = $request->get();
        $result = $this->Service->getMerchantOrderList($params);
        return writeJson(201, $result, '数据列表');
    }


    /**
     * @auth('商户订单审核反馈','运营管理')
     * @param Request $request
     * @param('id','订单ID','require')
     * @param('status','订单状态','require')
     * @return \think\response\Json
     */
    public function checkOrder(Request $request){
        $params = $request->param();
        $this->Service->checkOrder($params);
        return writeJson(201, '', '审核订单变更成功');
    }


    /**
     * @auth('查询执行人列表','运营管理')
     * @param Request $request
     * @param('page','页数','require')
     * @return \think\response\Json
     */
    public function getAllocationList(Request $request){
        $params = $request->get();
        $result = $this->Service->getAllocationList($params);
        return writeJson(201, $result, '数据列表');
    }

    /**
     * @auth('商户订单分配执行人','运营管理')
     * @param Request $request
     * @param('id','订单ID','require')
     * @param('author_id','执行人id','require')
     * @return \think\response\Json
     */
    public function Orderallocation(Request $request){
        $params = $request->param();
        $this->Service->Orderallocation($params);
        return writeJson(201, '', '执行人分配完成');
    }


    /**
     * @auth('商户商品审核列表','运营管理')
     * @param Request $request
     * @param('page','页数','require')
     * @return \think\response\Json
     */
    public function getMerchantProductList(Request $request){
        $params = $request->get();
        $result = $this->Service->getMerchantProductList($params);
        return writeJson(201, $result, '数据列表');
    }


    /**
     * @auth('商户商品审核反馈','运营管理')
     * @param Request $request
     * @param('id','商品id','require')
     * @param('status','状态','require')
     * @return \think\response\Json
     */
    public function checkProduct(Request $request){
        $params = $request->param();
        $this->Service->checkProduct($params);
        return writeJson(201, '', '审核商品变更成功');
    }


    /**
     * @auth('平台价值列表','运营管理')
     * @param Request $request
     * @return \think\response\Json
     */
    public function getPlatformList(){
        $result = $this->Service->getPlatformList();
        return writeJson(201, $result, '数据列表');
    }



    /**
     * @auth('商户账户变更','运营管理')
     * @param Request $request
     * @param('id','商户id','require|number')
     * @param('type','变动类型','require|number')
     * @param('num','数量','require|number')
     * @return \think\response\Json
     */
    public function assetChanges(Request $request){
        $params = $request->param();
        $msg = $this->Service->assetChanges($params);
        return writeJson(201, '', $msg.'成功');
    }

    /**
     * @auth('运营新增订单素材','运营管理')
     * @param Request $request
     * @param('order_id','订单id','require|number')
     * @param('materials','素材','require|array')
     * @return \think\response\Json
     */
    public function createMerchantMaterial(Request $request){
        $params = $request->post();
        $this->Service->createMerchantMaterial($params);
        return writeJson(201, '', '素材新增成功');
    }

    /**
     * @auth('审核写作文章','运营管理')
     * @param Request $request
     * @param('id','文章id','require')
     * @param('status','状态','require')
     * @return \think\response\Json
     */
    public function checkEvent(Request $request){
        $params = $request->param();
        $this->Service->checkEvent($params);
        return writeJson(201, '', '审核状态变更成功');
    }


    /**
     * @auth('订单话题配置','运营管理')
     * @param Request $request
     * @param('order_id','订单id','require')
     * @param('data','话题数组','require|array')
     * @return \think\response\Json
     */
    public function updateOrderTags(Request $request){
        $params = $request->param();
        $this->Service->updateOrderTags($params);
        return writeJson(201, '', '话题变更成功');
    }


    /**
     * @auth('订单整体小结','运营管理')
     * @param Request $request
     * @param('order_id','订单id','require')
     * @param('summary','小结内容','require')
     * @return \think\response\Json
     */
    public function updateOrderSummary(Request $request){
        $params = $request->param();
        $this->Service->updateOrderSummary($params);
        return writeJson(201, '', '编辑成功');
    }

    /**
     * @auth('审核人工回填地址','运营管理')
     * @param('id','文章id','require')
     * @param('check','审核状态','require')
     * @param('backfill_url','回填链接','require')
     * @param('reason','原因')
     * @param('feed_id','作品解析id')
     * @param Request $request
     * @return \think\response\Json
     */
    public function checkBackfillUrl(Request $request){
        $params = $request->param();
        $this->Service->checkBackfillUrl($params);
        return writeJson(201, '', '审核完成');
    }


    /**
     * @auth('发布平台账号查询','运营管理')
     * @param Request $request
     * @param('page','页数','require')
     * @param('platform_id','平台标识')
     * @param('username','绑定账号')
     * @param('in_ues','显示')
     * @return \think\response\Json
     */
    public function getAccountList(Request $request){
        $params = $request->get();
        $res = $this->Service->getAccountList($params);
        return writeJson(201, $res, '数据列表');
    }


    /**
     * @auth('查询渠道账号关系','运营管理')
     * @param Request $request
     * @return \think\response\Json
     */
    public function getPlatform(Request $request){
        $params = $request->get();
        $res = $this->Service->getPlatform($params);
        return writeJson(201, $res, '数据列表');
    }


    /**
     * @auth('查询可以关联的分发账号','运营管理')
     * @param Request $request
     * @return \think\response\Json
     */
    public function getReleaseUser(Request $request){
        $params = $request->get();
        $res = $this->Service->getReleaseUser($params);
        return writeJson(201, $res, '数据列表');
    }

    /**
     * @auth('发布平台账号新增','运营管理')
     * @param Request $request
     * @param('account','账号')
     * @param('password','密码')
     * @param('name','账号名','require')
     * @param('app_id','唯一id','require')
     * @param('platform_id','平台标识','require')
     * @param('remark','备注')
     * @param('uid','绑定账号id','require')
     * @param('pub_type','分发类型')
     * @param('category','垂类')
     * @param('home','主页','require')
     * @param('leader','组长')
     * @return \think\response\Json
     */
    public function addAccount(Request $request){
        $params = $request->post();
        $this->Service->addAccount($params);
        return writeJson(201, true, '添加成功');
    }


    /**
     * @auth('发布平台账号编辑','运营管理')
     * @param Request $request
     * @param('id','id','require')
     * @param('account','账号')
     * @param('password','密码')
     * @param('name','账号名','require')
     * @param('app_id','唯一id','require')
     * @param('platform_id','平台标识','require')
     * @param('remark','备注')
     * @param('uid','绑定账号id','require')
     * @param('pub_type','分发类型')
     * @param('category','垂类')
     * @param('home','主页','require')
     * @param('in_ues','显示隐藏')
     * @param('leader','组长')
     * @return \think\response\Json
     */
    public function upAccount(Request $request){
        $params = $request->param();
        $this->Service->upAccount($params);
        return writeJson(201, true, '更新成功');
    }



    /**
     * @auth('订单任务报表明细','运营管理')
     * @param Request $request
     * @param('order_id','订单id','require')
     * @param('start_time','开始时间')
     * @param('end_time','结束时间')
     * @return \think\response\Json
     */
    public function getOrderReport(Request $request){
        $params = $request->get();
        $result = $this->Service->getOrderReport($params);
        return writeJson(201, $result, '数据');
    }



    /**
     * @auth('分配执行人关联平台账号','运营管理')
     * @param Request $request
     * @param('app_id','平台账号','require')
     * @param('uids','执行人id数组','array')
     * @return \think\response\Json
     */
    public function setAccountCreator(Request $request){
        $params = $request->post();
        $this->Service->setAccountCreator($params);
        return writeJson(201, true, '设置成功');
    }

}
